import { reqCategoryList, reqBannersList, reqFloorList } from "@/api";

// Home的小仓库
const state = {
    categoryList: [],
    bannersList: [],
    floorList: []
};
const actions = {
    categorylist(context) {
        let result = reqCategoryList()
        result.then((response) => {
            if (response.code == 200) {
                context.commit("CATEGORYLIST", response.data)
            }
        }, (error) => {
            console.log(error);
        })


    },
    async getBannersList(context) {
        let banners = await reqBannersList()
        context.commit("GETBANNERSLIST", banners.data)
    },
    async getFloorList({ commit }) {
        let result = await reqFloorList()
        if (result.code == 200) {
            commit("GETFLOORLIST", result.data)
        }
    }
};
const mutations = {
    CATEGORYLIST(state, value) {
        state.categoryList = value
    },
    GETBANNERSLIST(state, value) {
        state.bannersList = value;
    },
    GETFLOORLIST(state, value) {
        state.floorList = value
    }
}
const getters = {}

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}